<template>
  <div class="dashboard-container">
    <!-- 欢迎信息 -->
    <div class="welcome-section">
      <div class="welcome-info">
        <h1>欢迎回来，{{ username }}</h1>
        <p class="time">{{ currentTime }}</p>
        <p class="welcome-text">欢迎使用校园外卖平台管理系统，祝您工作愉快！</p>
      </div>
      <!-- <div class="welcome-image">
        <img src="https://img.zcool.cn/community/01f9ea5c2f1428a8012029ac7e7a74.jpg@1280w_1l_2o_100sh.jpg" alt="欢迎图片">
      </div> -->
    </div>

   
    <!-- 快捷入口 -->
    <div class="quick-access">
      <h2 class="section-title">快捷入口</h2>
      <el-row :gutter="20">
        <el-col :span="6" v-for="(item, index) in quickAccessItems" :key="index">
          <el-card shadow="hover" class="quick-card" @click.native="navigateTo(item.path)">
            <div class="quick-icon">
              <i :class="item.icon"></i>
            </div>
            <div class="quick-title">{{ item.title }}</div>
            <div class="quick-desc">{{ item.description }}</div>
          </el-card>
        </el-col>
      </el-row>
    </div>

  
   
  </div>
</template>

<script>
export default {
  name: 'AdminDashboard',
  data() {
    return {
      username: '管理员',
      currentTime: '',
      mockData: {
        userCount: 1258,
        userIncrease: 25,
        merchantCount: 86,
        merchantIncrease: 3,
        orderCount: 9527,
        orderIncrease: 156,
        income: '25,689.00',
        todayIncome: '1,256.00'
      },
      quickAccessItems: [
        {
          title: '用户管理',
          icon: 'el-icon-user',
          description: '查看和管理用户信息',
          path: '/admin/users'
        },
        {
          title: '商家管理',
          icon: 'el-icon-house',
          description: '查看和管理商家信息',
          path: '/admin/merchants'
        },
        {
          title: '订单管理',
          icon: 'el-icon-s-order',
          description: '查看和处理订单',
          path: '/admin/orders'
        },
        {
          title: '轮播图管理',
          icon: 'el-icon-picture',
          description: '管理首页轮播图',
          path: '/admin/banners'
        }
      ],
      announcements: [
        {
          title: '系统更新通知',
          content: '校园外卖平台管理系统已更新至v1.2.0版本，新增轮播图管理功能，优化了订单处理流程。',
          date: '2025-06-12'
        },
        {
          title: '端午节放假通知',
          content: '根据学校安排，端午节期间（6月10日-6月12日）外卖平台配送时间可能会有调整，请及时通知商家做好准备。',
          date: '2025-06-08'
        },
        {
          title: '新商家入驻优惠活动',
          content: '为了丰富校园美食种类，平台将于下月开展新商家入驻优惠活动，请相关部门做好准备。',
          date: '2025-06-01'
        }
      ]
    }
  },
  created() {
    this.updateTime()
    // 每分钟更新一次时间
    setInterval(this.updateTime, 60000)
  },
  methods: {
    // 更新当前时间
    updateTime() {
      const now = new Date()
      const options = { 
        year: 'numeric', 
        month: 'long', 
        day: 'numeric', 
        weekday: 'long',
        hour: '2-digit',
        minute: '2-digit'
      }
      this.currentTime = now.toLocaleDateString('zh-CN', options)
    },
    
    // 导航到指定路径
    navigateTo(path) {
      this.$router.push(path)
    },
    
    // 刷新公告
    refreshAnnouncement() {
      this.$message.success('公告已更新')
    }
  }
}
</script>

<style scoped>
.dashboard-container {
  padding: 20px;
}

/* 欢迎区域样式 */
.welcome-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #1890ff 0%, #36cfc9 100%);
  border-radius: 8px;
  padding: 30px;
  margin-bottom: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.welcome-info {
  flex: 1;
}

.welcome-info h1 {
  font-size: 28px;
  margin: 0 0 10px 0;
}

.time {
  font-size: 16px;
  margin: 0 0 20px 0;
  opacity: 0.9;
}

.welcome-text {
  font-size: 16px;
  opacity: 0.9;
  line-height: 1.6;
}

.welcome-image {
  flex: 1;
  text-align: right;
}

.welcome-image img {
  max-width: 300px;
  max-height: 150px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 数据概览卡片样式 */
.data-overview {
  margin-bottom: 20px;
}

.data-card {
  height: 120px;
  display: flex;
  align-items: center;
  padding: 20px;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  margin-right: 15px;
}

.user-card .card-icon {
  background-color: rgba(24, 144, 255, 0.1);
  color: #1890ff;
}

.merchant-card .card-icon {
  background-color: rgba(82, 196, 26, 0.1);
  color: #52c41a;
}

.order-card .card-icon {
  background-color: rgba(250, 173, 20, 0.1);
  color: #faad14;
}

.income-card .card-icon {
  background-color: rgba(245, 34, 45, 0.1);
  color: #f5222d;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 14px;
  color: #909399;
  margin-bottom: 5px;
}

.card-value {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 5px;
}

.card-footer {
  font-size: 12px;
  color: #909399;
}

.increase {
  color: #52c41a;
  font-weight: bold;
}

/* 快捷入口样式 */
.section-title {
  font-size: 18px;
  margin-bottom: 15px;
  font-weight: bold;
  color: #303133;
}

.quick-access {
  margin-bottom: 20px;
}

.quick-card {
  height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
}

.quick-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.quick-icon {
  font-size: 36px;
  margin-bottom: 10px;
  color: #409EFF;
}

.quick-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 5px;
  color: #303133;
}

.quick-desc {
  font-size: 12px;
  color: #909399;
  text-align: center;
}

/* 系统公告样式 */
.announcement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.announcement-item {
  padding: 10px 0;
  border-bottom: 1px solid #EBEEF5;
}

.announcement-item:last-child {
  border-bottom: none;
}

.announcement-title {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.announcement-title i {
  color: #E6A23C;
  margin-right: 5px;
}

.announcement-date {
  margin-left: auto;
  font-size: 12px;
  color: #909399;
}

.announcement-text {
  font-size: 14px;
  color: #606266;
  padding-left: 20px;
  line-height: 1.6;
}
</style>
